﻿using MediatR;
using MyMES.Domain.W.Liststructure;
using MyMES.Error;
using MyMES.Infrastructure.Interface;
using MyMES.Read.API.Application.Commends.Productionorderss;

namespace MyMES.Read.API.Application.CommendHandlers.Productionorderss
{
    public class GetProductionorderssMaterCommendHandlers : IRequestHandler<GetProductionorderssMaterCommends, APIPaging<List<Materialmanagement>>>
    {

        private readonly IBaseRepository<Materialmanagement> materialmanagementRepository;

        public GetProductionorderssMaterCommendHandlers(IBaseRepository<Materialmanagement> materialmanagementRepository)
        {
            this.materialmanagementRepository = materialmanagementRepository;
        }

        /// <summary>
        /// 显示物品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<APIPaging<List<Materialmanagement>>> Handle(GetProductionorderssMaterCommends request, CancellationToken cancellationToken)
        {
            APIPaging<List<Materialmanagement>> result = new APIPaging<List<Materialmanagement>>();
            result.Code = APIEnum.查询成功;
            result.Msg = "查询成功";
            var sql = "select * from Materialmanagement where IsDelete = false ORDER BY MId DESC";
            var list = await materialmanagementRepository.SelectAsync(sql);
         
            result.data = list;
            return result;
        }
    }
}
